'''
Created on 2017年10月3日

@author: lml
'''

import tensorflow as tf

if __name__ == '__main__':
    with tf.Session() as default_session:
        v1 = tf.Variable(tf.constant(1))
        v2 = tf.Variable(tf.constant(0.2))
        name = "collection"
        tf.add_to_collection(name, v1)
        tf.add_to_collection(name, v2)
        c1 = tf.get_collection(name)
        init = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
        default_session.run(init)
        
        print(default_session.run(c1))
        default_session.run(v1.assign(value=3))
        print(default_session.run(c1))
        s = tf.reduce_sum(default_session.run(c1))
        print(default_session.run(s))
        